package matlap.server;

import java.util.List;

import matlap.client.services.order.OrderService;
import matlap.database.dao.DAOFactory;
import matlap.database.dao.OrderDAO;
import matlap.shared.Order;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */

public class OrderServiceImpl extends RemoteServiceServlet implements
		OrderService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8030762399773113970L;
	DAOFactory df = DAOFactory.getInstance();
	OrderDAO od = df.getOrderDAO();

	/**
	 * Turns back the orders number from the orders table.
	 */

	public int getOrdersNumber() {
		return od.getOrdersNumber();
	}

	/**
	 * Turns back all of the orders in Order list.
	 */

	public List<Order> getOrders() {
		return od.getOrders();

	}

	/**
	 * Turns back the orders name in Order list.
	 */

	public List<Order> selectOrdersName() {
		return od.selectOrdersName();

	}

	/**
	 * Turns back orders in Order list by adding orders name.
	 */

	public List<Order> getOrdersByName(String orderName) {
		return od.getOrdersByName(orderName);
	}

	/**
	 * Inserts orders into orders table by adding Order.
	 */

	@Override
	public void insertOrder(Order order) {
		od.insertOrder(order);
	}

	/**
	 * Deletes orders from orders by adding Order.
	 */

	@Override
	public void deleteOrder(Order order) {
		od.deleteOrder(order);
	}

	/**
	 * Updates orders in orders table by adding Order.
	 */

	@Override
	public void updateOrder(Order order) {
		od.updateOrder(order);
	}

	public List<Order> getMyOrders(String un) {
		return od.getMyOrders(un);
	}

	public int getMyOrdersNumber(String un) {
		return od.getMyOrdersNumber(un);
	}

}
